const { DataTypes } = require('sequelize')
const db = require('../database')
const crypto = require("crypto")

const User = db.define('user', {
    id: { type: DataTypes.INTEGER, primaryKey: true, notNull: true, autoIncrement: true },
    name:{type: DataTypes.STRING, notNull: true },
    account: { type: DataTypes.STRING, notNull: true, primaryKey: true },
    password: {
      type: DataTypes.STRING,
      notNull: true,
      set(value) {
        this.setDataValue(
          "password",
          crypto.createHash("md5").update(value).digest("hex")
        )
      },
    },
    
})


module.exports = User
